home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / GoldED Tools / GoldDock / TeXsupport / ARexx / TeXSkripte / Start_TeX.ged < prev    next >
Encoding:
Text File  |  1996-09-27  |  4.1 KB  |  150 lines

  1. /*RX
  2.  * AREXX        Name:Start_TeX.ged      Version:1.41    Date:27-Jul-91
  3.  *
  4.  This AREXX script saves and compiles the current GED view. The only
  5. (optional) argument is the format to be used. A '?' formatname will
  6. interactively ask for the format to use.
  7.  *
  8.  A command is send to the TeX server to compile the file. Hence a
  9. return value of 0 does not mean that the file compiled well, but only
  10. that the command was sent to the server and replied to.
  11.  *
  12. AUTHOR:
  13.  *      J\"org H\"ohle, March 91
  14.  *
  15.  *      small modifications for GoldED by Markus Aretz
  16. BUGS:
  17.  virtex doesn't like filenames with blanks (and ARexx parses them
  18. hardly too), so avoid them in file, directory *and* device names.
  19.  *
  20.  Does not like names relative to the local root, like ":foo/bar"
  21.  *
  22. FILES:
  23.  ENV:TEXFORMAT: default format used
  24.  REXX:namestruc
  25.  *
  26.  */
  27.  
  28. OPTIONS RESULTS                             /* enable return codes     */
  29.  
  30. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  31.     address 'GOLDED.1'
  32.  
  33. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  34. OPTIONS FAILAT 6                            /* ignore warnings         */
  35. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  36.  
  37. /* OPTIONS FAILAT 3 */
  38.  
  39. /**
  40. IF ~SHOW('L','rexxsupport.library') THEN
  41.         IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
  42.                 'REQUEST BODY "Can't open ''rexxsupport.library'!"'
  43.                 EXIT 20
  44.                 END
  45. **/
  46.  
  47. portname = 'Start_TeX'
  48. script   = 'TeX-server.ged'    /* no path required, message only       */
  49.  
  50. IF "" = GetClip("TEX    QUERY") THEN askformat = 0
  51. ELSE askformat = 1              /* ask interactively for format name    */
  52.  
  53. PARSE ARG format .
  54. IF "?" = format THEN DO
  55.         askformat= 1
  56.         format   = ""
  57.         END
  58. ELSE IF '&' = LEFT(format,1) THEN
  59.         format = SUBSTR(format,2)
  60.  
  61. 'QUERY FILE VAR LOADEDFILE'
  62. 'QUERY PATH VAR LOADEDDIR'
  63. IF RIGHT(loadeddir,1)~='/' & RIGHT(loadeddir,1)~=':' THEN
  64.         loadeddir = loadeddir||'/'
  65.  
  66. 'QUERY DOC VAR FULLNAME'
  67.  
  68. /* fullname = loadeddir||loadedfile */
  69.  
  70. PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
  71.  
  72. IF "TEX" ~= UPPER(RIGHT(loadedfile,3)) THEN DO
  73.         'REQUEST BODY "Sorry, filename must have an extension and end in `tex''."'
  74.         'UNLOCK'
  75.         EXIT 5
  76.         END
  77.  
  78. IF 0 = ivol THEN DO
  79.         direc = PRAGMA('D')
  80.         IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
  81.         fullname = direc||fullname
  82.         DROP direc
  83.         END
  84. DROP ivol idirs ibase
  85.  
  86. /* Save only if file has been modified */
  87. 'QUERY MODIFY VAR RESULT'
  88. IF RESULT = 'TRUE' THEN DO
  89.     'REQUEST BODY "File has been modified|Save it first?" BUTTON "_Yes|_No"'
  90.     IF RESULT='1' THEN 'SAVE ALL'
  91.     END
  92.  
  93. IF (SHOW('P', portname)) THEN DO
  94.     /* set the default format, modify it to suit your needs */
  95.     envformat = mygetenv("TEXFORMAT")
  96.     IF "" == format THEN DO
  97.         format = envformat
  98.         IF askformat | "" = envformat THEN DO
  99.             IF "" = format THEN format = 'plain'
  100.  
  101.             'REQUEST STRING VAR NFORMAT DEFAULT format BODY "Which format to use ?"'
  102.             /* "RESULT" if cancelled */
  103.             IF "RESULT" ~= NFORMAT THEN format = NFORMAT
  104.  
  105.             END /* askformat */
  106.         END /* format */
  107.  
  108.     /* If the server is already busy with some compilation, this will
  109.     wait till compilation finishes, this may take a long time */
  110.     /* no unlocking (like in MG) available */
  111.  
  112.     if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  113.  
  114.     'UNLOCK'
  115.     ADDRESS VALUE portname
  116.     'compile' format fullname
  117.     EXIT
  118.     END
  119. ELSE DO
  120.     /* The TeX server must be started first */
  121.     'REQUEST BODY "The TeX server '''script''' is not running !"'
  122.     'UNLOCK'
  123.     EXIT 5
  124.     END
  125.  
  126. SYNTAX:
  127.  
  128. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  129. 'UNLOCK'
  130. EXIT
  131.  
  132. mygetenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  133.    PARSE ARG name
  134.  
  135.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  136.         gives = readln(TEMPFILE)
  137.         CALL close TEMPFILE
  138.         END
  139.    ELSE gives = ""
  140.  
  141.    RETURN gives
  142.  
  143. mysetenv: procedure
  144.    PARSE ARG name,content
  145.  
  146.    ADDRESS COMMAND "SetEnv" name content
  147.  
  148.  
  149.    RETURN
  150.